{template 'common/header-storex'}
<div class="wn-main">
	<div class="wn-main__head">添加用户</div>
	<div class="wn-main__content">
		<div class="wn-tabs">
			<div class="wn-tabs__item wn-tabs__item--active">
				<a class="wn-tabs__link" href="{php echo $this->createWebUrl('shop_member', array('op' => 'display', 'storeid' => $_GPC['storeid']))}">用户管理</a>
			</div>
			<div class="wn-tabs__item">
				<a class="wn-tabs__link" href="{php echo $this->createWebUrl('shop_memberlevel', array('storeid' => $_GPC['storeid']))}">会员组管理</a>
			</div>
		</div>
		<form action="" class="form-horizontal form" method="post" onsubmit="return formcheck()">
			<input type="hidden" name="id" value="{$item['id']}">
			<input type="hidden" name="storeid" value="{$_GPC['storeid']}">
			<div class="panel-body">
				{if !empty($item)}
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">微信号</label>
					<div class="col-sm-9 col-xs-12">
						<span class='form-control-static'>{$item['from_user']}</span>
					</div>
				</div>
				{/if}
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">姓名</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="realname" id="realname" value="{$item['realname']}" class="form-control">
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">用户名</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="username" id="username" value="{$item['username']}" class="form-control" {if !empty($item)}readonly{/if}>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">手机</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="mobile" id="mobile" value="{$item['mobile']}" class="form-control">
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">{if !empty($id)}新{/if}密码</label>
					<div class="col-sm-9 col-xs-12">
						<input type="password" name="password" id="password" value="" class="form-control">
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">确认{if !empty($id)}新{/if}密码</label>
					<div class="col-sm-9 col-xs-12">
						<input type="password" name="password2" id="password2" value="" class="form-control">
					</div>
				</div>
				{if !empty($address_info)}
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">收货地址</label>
					<div class="col-sm-9 col-xs-12">
						<table class="table table-hover">
							<thead class="navbar-inner">
								<tr>
									<th style='width:100px'>省</th>
									<th style='width:100px'>市</th>
									<th style='width:100px'>区</th>
									<th style="width:70px;">详细地址</th>
								</tr>
							</thead>
							<tbody>
								{loop $address_info $info}
								<tr>
									<td>{$info['province']}</td>
									<td>{$info['city']}</td>
									<td>{$info['district']}</td>
									<td>{$info['address']}</td>
								</tr>
								{/loop}
							</tbody>
						</table>
					</div>
				</div>
				{/if}
				{if !empty($item)}
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">订房积分</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="score" id="score" value="{$item['score']}" class="form-control">
					</div>
				</div>
				{/if}
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">用户类型</label>
					<div class="col-sm-9 col-xs-12">
						<label class="radio-inline">
							<input type="radio" name="isauto" class="isauto_radio" value="1" {if $item['isauto'] == 1}checked{/if}/>微信用户
						</label>
						<label class="radio-inline">
							<input type="radio" name="isauto" class="isauto_radio" value="0" {if $item['isauto'] == 0}checked{/if}/>会员用户
						</label>
						<span class='help-block'>会员用户显示房型的会员价，微信用户显示房型的优惠价</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">是否绑定微信号</label>
					<div class="col-sm-9 col-xs-12">
						<label class="radio-inline">
							<input type="radio" name="userbind" value="1" {if $item['userbind'] == 1}checked{/if}/>绑定
						</label>
						<label class="radio-inline">
							<input type="radio" name="userbind" value="0" {if $item['userbind'] == 0}checked{/if}/>不绑定
						</label>
						<span class='help-block'>绑定之后，此账户与微信用户绑定，帐号不能从其他微信登录</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">状态</label>
					<div class="col-sm-9 col-xs-12">
						<label class="radio-inline">
							<input type="radio" name="status" value="1" {if $item['status'] == 1}checked{/if}/>启用
						</label>
						<label class="radio-inline">
							<input type="radio" name="status" value="0" {if $item['status'] == 0}checked{/if}/>禁用
						</label>
						<span class='help-block'>禁用以后用户无法登录</span>
					</div>
				</div>
			</div>
			<div class="form-group col-sm-12">
				<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
				<input type="hidden" name="token" value="{$_W['token']}" />
			</div>
		</form>
	</div>
</div>
<div class="modal fade" id="store-modal" tabindex="-1" role="dialog" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				<h4 class="modal-title" id="myModalLabel">选择你要添加的店铺权限</h4>
			</div>
			<div class="modal-body clearfix form-horizontal">
			
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
				<button type="button" class="btn btn-primary" data-dismiss="modal" id="addPermission">确定</button>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
	kindeditor($('.richtext-clone'));
	function formcheck() {
		var isauto = $('input[name="isauto"]:checked').val();
		if (isauto == 0) {
			if ($("#realname").isEmpty()) {
				Tip.select("realname", "请填写姓名!", "right");
				return false;
			}
			if ($("#username").isEmpty()) {
				Tip.select("username", "请填写用户名!", "right");
				return false;
			}
			if (!$("#mobile").isMobile()) {
				Tip.select("mobile", "请填写正确的手机!", "right");
				return false;
			}
		}
		var check_pass = 1;
		{if !empty($id)}
			if ($("#password").isEmpty() && $("#password2").isEmpty()) {
				check_pass = 0;
			}
		{/if}
		if (check_pass) {
			if ($("#password").isEmpty()) {
				Tip.select("password", "请填写{if !empty($id)}新{/if}密码!", "right");
				return false;
			}
			if ($("#password2").isEmpty()) {
				Tip.select("password2", "请填写确认{if !empty($id)}新{/if}密码!", "right");
				return false;
			}
			if ($.trim($("#password").val()) != $.trim($("#password2").val())) {
				Tip.select("password2", "两次密码不一致，请确认!", "right");
				return false;
			}
		}
		return true;
	}
</script>